#ifndef __MAINHANDLER_HPP__
#define __MAINHANDLER_HPP__

/**
 *  This file is part of PennerBot
 *
 *  Copyright (C) 2010 microkernel
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <queue>
#include <vector>

#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/shared_ptr.hpp>

#include <core/bot.hpp>
#include <core/updatecheck.hpp>

#include <console/statuslistener.hpp>
#include <console/log.hpp>

namespace PBot
{
namespace Console
{

class Main
{
public:

    Main();
    virtual ~Main();

    int Start();
    void Stop();

private:
    void LoadFromFile();
    unsigned int CreateThreads();

    void ThreadDo();

    bool running;

    StatusListener& listener;
    Log log;
    Core::UpdateCheck* updateCheck;
    std::vector<Core::Bot*> botList;
    std::queue<Core::Bot*> bots;
    unsigned int numActiveBots;

    boost::recursive_mutex mutex;

    typedef boost::shared_ptr<boost::thread> bthread;

    std::vector<bthread> threads;

};

}
}


#endif // __MAINHANDLER_HPP__
